<template>
  <u-tabbar
    style="height: 60px; padding-bottom: 20rpx"
    :value="tabbarValue"
    @change="onTabbarChange"
    :safeAreaInsetBottom="false"
  >
    <u-tabbar-item text="首页">
      <image
        class="u-page__item__slot-icon"
        slot="inactive-icon"
        src="../static/shouye.png"
      ></image>
      <image
        class="u-page__item__slot-icon"
        slot="active-icon"
        src="../static/shouye.png"
      ></image>
    </u-tabbar-item>
    <!-- 		<u-tabbar-item text="护工">
			<image class="u-page__item__slot-icon" slot="inactive-icon" src="../static/icon_hugong.png"></image>
			<image class="u-page__item__slot-icon" slot="active-icon" src="../static/icon_hugong.png"></image>
		</u-tabbar-item> -->
    <u-tabbar-item text="订单">
      <image
        class="u-page__item__slot-icon"
        slot="inactive-icon"
        src="../static/dingdan.png"
      ></image>
      <image
        class="u-page__item__slot-icon"
        slot="active-icon"
        src="../static/dingdan.png"
      ></image>
    </u-tabbar-item>
   <!-- <u-tabbar-item text="我的">
      <image
        class="u-page__item__slot-icon"
        slot="inactive-icon"
        src="../static/wode.png"
      ></image>
      <image
        class="u-page__item__slot-icon"
        slot="active-icon"
        src="../static/wode.png"
      ></image>
    </u-tabbar-item> -->
  </u-tabbar>
</template>

<script>
export default {
  components: {},
  props: {
    tabbarValue: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      //   tabbarValue: 0,
      titles: ["首页", "订单", "我的"],
      roles: "",
    };
  },
  onLoad() {
    this.roles = uni.getStorageSync("ROLES");
  },
  onPullDownRefresh() {
    this.refresh();
  },
  onReachBottom() {
    this.loadMore();
  },
  methods: {
    onTabbarChange(e) {
      //   this.tabbarValue = e;
      uni.setNavigationBarTitle({
        title: this.titles[e],
      });
      this.$emit("onTabBarChange", e);
    },
    refresh() {
      const index = {
        0: () => {
          uni.stopPullDownRefresh();
        },
        1: () => {
          uni.stopPullDownRefresh();
        },
        2: () => {
          this.$refs.myOrderList.refresh();
        },
        3: () => {
          uni.stopPullDownRefresh();
        },
      };
      index[this.tabbarValue]();
    },
  },
};
</script>

<style></style>
